import axios from "axios"

const instance = axios.create({
  baseURL: "http://localhost:9000/api",
  timeout: 3000,
});

instance.interceptors.request.use(
  // 正确的请求拦截
  function (config) {
    config.headers["authorization"] = "Bearer tokenContent";
    return config;
  },

  // 错误的请求拦截
  function (err) {
    return Promise.reject(err);
  }
);

instance.interceptors.response.use(
  // 正确的请求拦截
  function (response) {
    return response.data;
  },

  // 错误的请求拦截
  function (err) {
    return Promise.reject(err);
  }
);

export default instance